#include <stdio.h>
#include "ClusterInfo.h"

/*
 * Compares two cluster according to the size (primary) and score (secondary).
 */
int comparator(const void *cluster1, const void *cluster2)
{
    clusterInfo * cl1 = *(clusterInfo**)cluster1;
    clusterInfo * cl2 = *(clusterInfo**)cluster2;
    int diff = cl2 -> size - cl1 -> size;
    /* We return an opposite value to cause qsort to sort descending other then its default ascending manner*/
    if (!diff){
    	if (cl2 -> score > cl1 -> score){
    		return 1;
    	}
    	return -1;
    }
    return diff;
}
